﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using com.intellitack.layar.library;
using com.intellitack.layar.sample;

namespace TestHarness
{
    class Program
    {
        static void Main(string[] args)
        {
            ////Get the Sample Response
            //ILayerObject response = createSampleResponse();
            ////Get the Serialization String
            //string serializedPOI = LayarUtilities.TestSerialization(response);


            SampleLayar mySampleLayarApp = new SampleLayar();
            Type myType = mySampleLayarApp.GetType();
            string assemblyQualifiedName = myType.AssemblyQualifiedName;

            Console.WriteLine(assemblyQualifiedName);


            //Test Reflection
            string targetType = ConfigurationManager.AppSettings.Get("LayarApplicationClass");
            Type layarType = Type.GetType(targetType);
            
            System.Object layarApplication = Activator.CreateInstance(layarType);
            if (layarApplication is ILayerApplication)
            {
                Console.WriteLine("Sweet");
            }
            //Wait for Enter
            Console.ReadLine();
        }

        protected static void testSerialization() 
        {
            LayarResponse response = new LayarResponse();
            response.layer = "snowy4";
            response.morePages = false;

            //Instantiate a new POI
            PointOfInterest poi = new PointOfInterest();
            //Fill out some sample data
            poi.distance = 100;
            poi.attribution = "This is a test layer POI provider";
            poi.title = "This is a sample POI title";
            poi.lon = 4.884339m;
            poi.lat = 52.380544m;
            poi.line4 = "RADIOLIST-None,CustSlider-None";
            poi.line3 = "SEARCHBOX = asdfdgxdg";
            poi.line2 = "DevlId = 896Settings: range=1000";
            poi.type = 0;
            poi.id = "Test_1";
            //Create a couple Actions
            poi.actions.Add(new POIAction("http://test.com/id=1", "Visit"));
            poi.actions.Add(new POIAction("tel:9999999999", "Call"));

            response.hotspots.Add(poi);
            Console.WriteLine(response.Serialize());

        }
        /// <summary>
        /// Creates a sample Point of Interest Object
        /// </summary>
        /// <returns>Sample Point of Interest Object
        /// </returns>
        protected static ILayerObject createSampleResponse() 
        {
            //Instantiate a new Request
            LayarResponse response = new LayarResponse();
            //Fill out some sample data
            response.layer = "snowy4";
            response.errorString = "ok";
            response.morePages = false;
            response.errorCode = 0;
            response.nextPageKey = null;
            
            //Instantiate a new POI
            PointOfInterest poi = new PointOfInterest();
            //Fill out some sample data
            poi.distance = 100;
            poi.attribution = "This is a test layer POI provider";
            poi.title = "This is a sample POI title";
            poi.lon = 4.884339m;
            poi.lat = 52.380544m;
            poi.line4 = "RADIOLIST-None,CustSlider-None";
            poi.line3 = "SEARCHBOX = asdfdgxdg";
            poi.line2 = "DevlId = 896Settings: range=1000";
            poi.type = 0;
            poi.id = "Test_1";
            //Create a couple Actions
            poi.actions.Add(new POIAction("http://test.com/id=1", "Visit"));
            poi.actions.Add(new POIAction("tel:9999999999","Call"));

            //Add Point of Interest to set of hot spots
            response.hotspots.Add(poi);

            return response;

        }
        
    }
}
